package com.xpf.shardingtabledemo.shardingdtable.strategy;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class MonthShardingStrategy implements IShardingTableStrategy {
    @Override
    public String getActualTableName(String originalTableName) {
        LocalDateTime now = LocalDateTime.now();
        int year = now.getYear();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
        String formattedMonth = now.format(formatter);
        return originalTableName + "_" + year + "_" + formattedMonth;
    }
}
